const { data } = require('./mock')
const bodyParser = require('body-parser')

module.exports = app => {
    app.use(bodyParser.json())
    app.post('/api/list', (req, res) => {
        let { status } = req.body
        console.log(req.body)
        // eslint-disable-next-line no-const-assign
        status = status * 1
        if (status) {
            res.send({
                code: 200,
                data: data.filter(item => item.status === status)
            })
        } else {
            res.send({
                code: 200,
                data
            })
        }
        // res.send({
        //     code:200,
        //     data
        // })

    })

}
